<?php

use yii\db\Migration;

class m210915_111731_minerva_ftp_servers extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%minerva_ftp_servers}}', [
            'id' => "int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id'",
            'name' => "char(16) NULL COMMENT 'ftp名称'",
            'ip_addr' => "char(32) NULL COMMENT 'ftp ip地址'",
            'ip_port' => "int(11) NULL DEFAULT '21' COMMENT 'ftp端口号'",
            'username' => "char(16) NULL COMMENT 'ftp用户名'",
            'password' => "char(16) NULL COMMENT 'ftp密码'",
            'local_path' => "char(255) NULL COMMENT 'ftp本地目录'",
            'share_name' => "char(32) NULL COMMENT '主目录 共享名'",
            'disk_sizes' => "bigint(20) NULL DEFAULT '0' COMMENT '硬盘大小'",
            'free_sizes' => "bigint(20) NULL DEFAULT '0'",
            'server_group_name' => "char(16) NULL COMMENT '服务器组名称'",
            'OnLineNum' => "int(11) NULL DEFAULT '1'",
            'IsOutOfService' => "int(11) NULL DEFAULT '0'",
            'is_deleted' => "tinyint(1) NULL DEFAULT '0' COMMENT '删除(1删除,0未删)'",
            'status' => "tinyint(4) NULL DEFAULT '1' COMMENT '-1:已删除,0:禁用,1:正常'",
            'created_at' => "int(11) NOT NULL DEFAULT '0' COMMENT '创建时间'",
            'updated_at' => "int(11) NOT NULL DEFAULT '0' COMMENT '修改时间'",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='大数据系统-ftp服务器表'");
        
        /* 索引设置 */
        $this->createIndex('idx_mine_ftp_servers_name','{{%minerva_ftp_servers}}','name',0);
        
        
        /* 表数据 */
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%minerva_ftp_servers}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

